<html>
<head>

<?php echo $this->headLink()->prependStylesheet($this->baseUrl().'/res/layout.css'); ?>

<script type="text/javascript">
function mouseOver(id)
{
document.getElementById((id+"Pic")).src ="/pics/buttons/button"+id+"Hover.jpg";
}
function mouseOut(id)
{
document.getElementById(id+"Pic").src ="/pics/buttons/button"+id+".jpg";
}
</script>
</head>
<body>
<div class="header">
	<div class="info">
		<?php
			$user=new Zend_Session_Namespace('user');
			if ($user->username != "") {
				echo ("Your are currently logged in as: ".$user->username."<br/>");
				echo ("Click <a href='/logout'>here</a> to log out.<br/>");
			}
			else{
				echo ("Your are currently not logged in.<br/>");
				echo ("Click <a href='/login'>here</a> to log in.<br/>");
			}
		?>
		<!-- TIMEOUT DIV -->
		<div id="counter"></div> 

		<script type="text/javascript">
		 var milisec = 0;
 
		 <?php 
			$login_session = new Zend_Session_Namespace('login_session');
			if ($login_session->start_time != "") {
				echo ('var minutes = ' . floor(($login_session->start_time + $login_session->end_seconds - time()) / 60) . ';');
				echo ('var seconds = ' . (($login_session->start_time + $login_session->end_seconds - time()) % 60) . ';');
		 ?>	

		function sessionTimedOut() {
			window.location = "/login";
		} 

		function display(){ 
		 if (milisec <= 0){ 
		    milisec = 9;
		    seconds -= 1;
		 } 
		 if (seconds <= -1) {
			seconds = 59;
			minutes -= 1;
		 }
		 if (minutes <= -1) {
			millsec = 0;
			seconds = 0;
			minutes += 1;
		 }
		 else {
			 milisec -= 1;
			 document.getElementById("counter").innerHTML = "Time Left: " + minutes; 
			 setTimeout("display()",100);
		 }
 
		 if (minutes == 0 && seconds == 0 && milisec == 0) {
			document.getElementById("counter").innerHTML = "Session Timed Out.";
			setTimeout('sessionTimedOut()', 3000);
		 }
		} 
		<?php
			echo ('display();');
			}
		?>

		</script>
	</div>
</div>
<div class="links">
	<table>
		<tr>
		<td><a href="/index">Search</a></td>
		
		<?php
		$user=new Zend_Session_Namespace('user');
		if ($user->username != "") {
			echo ("<td><a href='/logout'>Logout</a></td>");
		}
		else
			echo ("<td><a href='/login'>Login</a></td>");
		?>
		</tr>
	</table>
</div>

<div class="content"> 
<?php echo $this->layout()->content; ?>
</div>
</body>
</html>
